<% layout('/layouts/default.html', {title: '增加反馈', libs: ['validate','fileupload']}){ %>
<div class="main-content">
    <div class="box box-main">
        <#form:form id="inputForm" model="${dcSupTaskFeedback}" action="${ctx}/feedback/dcSupTaskFeedback/addFeedbackFunc" method="post" class="form-horizontal">
        <div class="box-body">
            <div class="row" style="height: 100%;min-height: 270px">
                <div class="col-xs-12" style="margin-top: 20px;">
                    <div class="form-group">
                        <label class="control-label col-sm-2" title="">
                            <span class="required ">*</span> ${text('起止时间')}：<i
                                class="fa icon-question hide"></i></label>
                        <div class="col-sm-10">
                            <div class="form-inline" style="padding-left: 0px !important;margin: 0px !important;">
                                <#form:hidden path="taskId" />
                                <#form:hidden path="actionId" />
                                <#form:hidden path="feedbackStatus" />
                                <#form:input path="feedbackEndTimeStr" readonly="true" maxlength="20" class="form-control laydate required dateCheck1" data-type="datetime" data-format="yyyy-MM-dd HH:mm" style="width:245px" placeholder="结束时间" /> 至
                                <#form:input path="feedbackEndTime" readonly="true" maxlength="20" class="form-control laydate required dateCheck" dataFormat="datetime" data-type="datetime" data-format="yyyy-MM-dd HH:mm" style="width:245px" placeholder="结束时间" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="box-footer">
            <div class="row" style="text-align: right;">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('确 定')}</button>&nbsp;
                    <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
                </div>
            </div>
        </div>
    </#form:form>
</div>
</div>
<% } %>
<script>
    var date = $("#feedbackEndTimeStr").val()+':00';
    var date1 =0
    laydate.render({
        elem: '#feedbackEndTimeStr',
        format: 'yyyy-MM-dd HH:mm',
        min: date,
        type:'datetime',
        done: function (value, date, endDate) {
            var startDate = new Date(value).getTime();
            var endTime = new Date($('#feedbackEndTime').val()).getTime();
            if ($('#feedbackEndTime').val()==''){
            }
            if (endTime < startDate) {
              $('#feedbackEndTime').val('')
            }
        }
    })
   $('#feedbackEndTime').click(function () {
       // console.log($('#feedbackEndTime').val(date))
   })


    laydate.render({ //结束时间
        elem: '#feedbackEndTime',
        format: 'yyyy-MM-dd HH:mm',
        type:'datetime',
        done: function (value, date, endDate) {
            var startDate = new Date($('#feedbackEndTimeStr').val()).getTime();
            var endTime = new Date(value).getTime();
            if (endTime <= startDate) {
                // $('#feedbackEndTime').val($('#feedbackEndTimeStr').val());
                js.showMessage("时间不能小于所选的开始时间", null, 'warning');
                $('#feedbackEndTime').val('')
            }
        }
    })
    // jQuery.validator.addMethod("dateCheck", function(v1,v2) {
    //
    //     var date1= $("#feedbackEndTimeStr").val();
    //     var startLogTimeDate = new Date(Date.parse(date1.replace(/-/g, "/"))).getTime();
    //     var date2=  $("#feedbackEndTime").val();
    //     var endLogTimeDate = new Date(Date.parse(date2.replace(/-/g, "/"))).getTime();
    //     if(endLogTimeDate<=startLogTimeDate){
    //         return false;
    //     }else{
    //         return true;
    //     }
    // }, "结束时间应大于开始时间");

    $("#inputForm").validate({
        submitHandler: function(form) {
            js.ajaxSubmitForm($(form), function(data) {
                js.showMessage(data.message);
                if (data.result == Global.TRUE) {
                    js.closeCurrentTabPage(function(contentWindow) {
                        // contentWindow.page();
                    });
                }
            }, "json");
        }
    });
</script>